package com.sms.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 连接数据库
 *
 */

public class ConnectDB {
	public static Connection getConnection() {
		Connection conn = null;
		try {
			String driver = "com.mysql.jdbc.Driver";
			String url = "jdbc:mysql://localhost:3306/sms";
			String user = "root";
			String psw = "123456";
			Class.forName(driver);	//加载驱动
			conn = DriverManager.getConnection(url, user, psw);
			return conn;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		} 
		
	}

}
